package java6681.lesson09;

import java.util.Scanner;


public class PhoneNumberString6681 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("输入手机号：");
        String line = sc.nextLine();
        String s = isPhoneNumber6681(line);
        System.out.println(s);
    }
    public static String isPhoneNumber6681(String s) {
        StringBuilder errMesage = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (s.length() != 11) {
                return errMesage.append("手机号码必须为11位数的,请重新输入").toString();
            }
            if (s.startsWith("13") || s.startsWith("15") ||
                    s.startsWith("17") || s.startsWith("18")) {
            } else {
                return errMesage.append("手机号码必须为为13,15,17,18,请重新输入").toString();
            }

            if (ch >= '0' && ch <= '9') {
            } else {
                return errMesage.append("号码有不是数字的,请重新输入").toString();
            }


        }
        return errMesage.append("手机号正确").toString();
    }
}